<?php

require_once 'Framework/Controller/Action.php';

require_once 'application/models/Stat/Access.php';
require_once 'application/models/Stat/Users.php';

class StatController extends Framework_Controller_Action
{
	
    public function init()
    {
		$this->view->adminnum = $this->session->get('adminnum');
		$this->view->current_page="stat";
		if (!$this->session->get('authorize'))	{
			$this->_redirect('/admin/');
		}
    }
    
    public function indexAction()
    {
    	if ($this->getRequest()->getMethod()=='POST')
		{
			$year_from = $this->getRequest()->getParam('from_year');
			$month_from = $this->getRequest()->getParam('from_year');
		}
		$this->view->main_page_visitors = Stat_Access::getAccess(0);
		$this->view->all_pages_visitors = Stat_Access::getAccess(-1);
		$this->view->new_users = Stat_Users::getNewUsers(1);
		$this->view->new_guests = Stat_Users::getNewUsers(0);
        $this->render();
    }
	
	public function pagesAction()
    {
		$this->view->
        $this->render();
    }
	
	public function roomsAction()
	{
		$this->view->rooms = Stat_Access::getTotalAccessByRoom();
		$this->render();
	}
}
